package main

import (
	"html/template"
	"net/http"

	"github.com/gorilla/mux"
)

type Todo struct{
	Title string
	Done bool
}

type TodoPageData struct {
	PageTitle string
	Todos []Todo
}


func main(){
	tmp := template.Must(template.ParseFiles("layout.html"))
	
	r := mux.NewRouter()
	r.HandleFunc("/",func(w http.ResponseWriter, r *http.Request) {
		// encapsulate data
		data := TodoPageData{
			PageTitle: "Todo-List",
			Todos: []Todo{
				{"eat",true},
				{"drink",true},
				{"sleep",false},
			},
		}
		// return template
		tmp.Execute(w,data)
	})

	// start server
	http.ListenAndServe(":8080",r)

}